faApp.controller('SwitchListCtrl',['$scope','switchService','$location','$controller','$route',
  function($scope,switchService,$location,$controller,$route) {   

    $controller('BaseCtrl', {$scope: $scope}); 

    $scope.switchs = [];
    $scope.loading = true;

    $scope.$watch('config',function(){
      switchService.switchList($scope.config).then(function(json){
        $scope.switchs = json.list;
        $scope.pager = json.pager;
        $scope.loading = false;
      });
    },true);

    $scope.changeSwitch = function(id,status){

      switchService.switchUpdate({id:id,sValue:status}).then(function(json){
        if (json.statusCode){
          alert("出错了:" + json.statusCode);
        }else{
          $route.reload();
        }
      });
    }
  }]);